import Vue from 'vue';
import Vuex from 'vuex';

import storeModules from './modules/index.js';
import createPersistedState from 'vuex-persistedstate';  


Vue.use(Vuex);

const httpFn = (api, data) => {
	return new Promise((resolve, reject) => {
		api(data).then(({ data: res }) => {
			if (res.code === '000000') {
				return resolve(res.resultBody);
			}
			reject(res);
		});
	});
};

export default new Vuex.Store({
	state: {
		showloading: false,
		exclude: [],
	},
	mutations: {
		changeMask(state, status) {
			if (status === 'start') {
				state.showloading = true;
			} else {
				state.showloading = false;
			}
		},
		operateExclude(state, component) {
			if (component === 0) {
				state.exclude = [];
			} else {
				state.exclude.push(component);
			}
		},
	},
	actions: {
		
	},
	modules: Object.assign({}, storeModules),
	plugins: [  
		createPersistedState({  
			storage: window.localStorage, // 或者使用 sessionStorage  
		}),  
	], 
});
